package com.xdb.sqlparser.dialect.oracle.ast.statement;

import java.util.ArrayList;
import java.util.List;

import com.xdb.sqlparser.ast.SQLCommentHint;
import com.xdb.sqlparser.ast.statement.SQLSelectQueryBlock;
import com.xdb.sqlparser.dialect.oracle.ast.clause.OracleModelClause;
import com.xdb.sqlparser.dialect.oracle.visitor.OracleASTVisitor;
import com.xdb.sqlparser.util.SQLUtils;
import com.xdb.sqlparser.visitor.SQLAstVisitor;

public class OracleSelectQueryBlock extends SQLSelectQueryBlock {

	private final List<SQLCommentHint> hints = new ArrayList<SQLCommentHint>(1);

	private OracleSelectHierachicalQueryClause hierachicalQueryClause;
	private OracleModelClause modelClause;

	public OracleSelectQueryBlock() {

	}

	public OracleModelClause getModelClause() {
		return modelClause;
	}

	public void setModelClause(OracleModelClause modelClause) {
		this.modelClause = modelClause;
	}

	public OracleSelectHierachicalQueryClause getHierachicalQueryClause() {
		return this.hierachicalQueryClause;
	}

	public void setHierachicalQueryClause(OracleSelectHierachicalQueryClause hierachicalQueryClause) {
		this.hierachicalQueryClause = hierachicalQueryClause;
	}

	public List<SQLCommentHint> getHints() {
		return this.hints;
	}

	@Override
	protected void accept0(SQLAstVisitor visitor) {
		if (visitor instanceof OracleASTVisitor) {
			accept0((OracleASTVisitor) visitor);
			return;
		}

		super.accept0(visitor);
	}

	protected void accept0(OracleASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, this.hints);
			acceptChild(visitor, this.selectList);
			acceptChild(visitor, this.into);
			acceptChild(visitor, this.from);
			acceptChild(visitor, this.where);
			acceptChild(visitor, this.hierachicalQueryClause);
			acceptChild(visitor, this.groupBy);
			acceptChild(visitor, this.modelClause);
		}
		visitor.endVisit(this);
	}

	public String toString() {
		return SQLUtils.toOracleString(this);
	}
}
